jquery ternary operation Syntax:var value = condition? value1:value2;Explanation: Set a variable value, judge according to the condition, if the condition is true, set value=value1, otherwise value=value2Instance:Prop Properties:$ (this). Prop (' checked '): Represents the value that gets the Checked property,$ (this). Prop (' checked ', True/false): Indicates that the value of the set checked property is T
12345678 9Ten One A - - the - - - + - + A at - - - - - in - to + - the * $Panax Notoginseng - the + the the -Knowledge Points:The prop () method sets or returns the attributes and values of the selected elementWhen the method is used to return a property value, the value of the first matching element is returned.When the method is used to set property values, one or more property/value pairs are set for the matching element collectionEach () method specifies the function to run for each matchin
Conditional (ternary) operator (?:)
The conditional operator?: accepts three operands, which is the only ternary operator in C #.
Return one of the following two expressions, as appropriate.
Test? Expression1:expression2
The expression expression1 returned when test is true. may be a comma expression.
The expression expression2 returned when test is false. may be a comma expression.
?: operator can be
Use of ternary operators in js and js ternary Operators
The outer layer is false, which is determined step by step to the inner layer.
$ Scope. nums = 700;$ Scope. result = ($ scope. nums> 300 )? ($ Scope. nums> 400 )? ($ Scope. nums> 500 )? ($ Scope. nums> 600 )? 'Airplane ': 'high-speed rail': 'auto': 'coach ': 'no ';Console. log ($ scope. result );
Small Example of simple use of operators (switch butto
smarter usage.Many ternary usages can be derived from the constant changes. The following is a section of jquery codeThe code is as follows:
flag? $ (' body '). addclass (' hover '): $ (' body '). Removeclass (' hover ');
Even more perverted.The code is as follows:
$ ('. Item ') [flag? ' AddClass ': ' Removeclass '] (' hover ')
The code above looks rather confusing. Because when flag = True, the cod
make your code look more refreshing, clear structure.
A little smarter usage.Many ternary usages can be derived from the constant changes. The following is a section of jquery code
Copy Code code as follows:
Flag? $ (' body '). addclass (' hover '): $ (' body '). Removeclass (' hover ');
even more perverted.
Copy Code code as follows:
$ ('. Item ') [flag? ' AddClass
mounting: Door mounting
The code is brilliant.
Such if else judgments are often made in daily use. In particular, it is more harmonious to use the ternary element when there are many nesting elements, which can make your code look more fresh and have a clear structure.
Usage with a little clevernessThrough constant changes, many ternary usage can be derived. The following
? No mounting: Door mounting
The code is brilliant.
Such if else judgments are often made in daily use. In particular, it is more harmonious to use the ternary element when there are many nesting elements, which can make your code look more fresh and have a clear structure.Usage with a little cleverness
Through constant changes, many ternary usage can be derived. The following
to use the ternary element when there are many nesting elements, which can make your code look more fresh and have a clear structure.
Usage with a little clevernessThrough constant changes, many ternary usage can be derived. The following jquery codeCopy codeThe Code is as follows:Flag? $ ('Body'). addClass ('hover '): $ ('body'). removeClass ('hover ');Even mor
mounting: door mounting
The code is brilliant.
Such if else judgments are often made in daily use. in particular, it is more harmonious to use the ternary element when there are many nesting elements, which can make your code look more fresh and have a clear structure.
Usage with a little clevernessThrough constant changes, many ternary usage can be derived. The following
PHP Ternary operator Knowledge Summary
Ternary operator syntax: condition? Result 1: Result 2 Description: The position in front of the question mark is judged by the condition, and if the condition is satisfied when the result is 1, the result 2 is not satisfied. Let's take a detailed discussion below.
Today in the change paper online encountered a statement can not understand:
?
1$if_summary = $row [' if
You are welcome to learn PHP ternary operator here! Here are some of the highlights that we've compiled for you. I hope you will learn here! Ternary operator syntax: condition? Result 1: Result 2 Description: The position in front of the question mark is judged by the condition, and if the condition is satisfied when the result is 1, the result 2 is not satisfied. Let's take a detailed discussion below.
$i
PHP ternary operator detailed, operator
Today in the change paper online encountered a statement can not understand:$if _summary = $row [' if_summary ']==2? ' Yes ': ' No ';Later found in Baidu is the ternary operator of PHPThe meaning of this sentence is equal toif ($row [' if_summary ']==2) {$if _summary= "yes";}else{$if _summary= "No";}The function of the ternary
PHP ternary operator Knowledge Rollup, operator summary
Today in the change paper online encountered a statement can not understand:
$if _summary = $row [' if_summary ']==2? ' Yes ': ' No ';
Later found in Baidu is the ternary operator of PHP
The meaning of this sentence is equal to
if ($row [' if_summary ']==2) {$if _summary= "yes";} else{$if _summary= "No";}
The function of the
Today in the change paper online encountered a statement can not understand:
$if _summary = $row [' if_summary ']==2? ' Yes ': ' No ';
Later found in Baidu is the ternary operator of PHP
The meaning of this sentence is equal to
if ($row [' if_summary ']==2) {
$if _summary= "yes";
}else{
$if _summary= "No";
}
The function of the ternary operator is consistent with the "if...else" process statement, which is
This article mainly introduces PHP ternary operators, interested in the reference of friends, I hope to be helpful to everyone.
Ternary operator syntax: condition? Result 1: Result 2 Description: The position in front of the question mark is judged by the condition, and if the condition is satisfied when the result is 1, the result 2 is not satisfied. Let's take a detailed discussion below.
Today in the ch
Ternary operator syntax: condition? Result 1: Result 2 Description: The position in front of the question mark is judged by the condition, and if the condition is satisfied when the result is 1, the result 2 is not satisfied. Let's take a detailed discussion below.
Today in the change paper online encountered a statement can not understand:
$if _summary = $row [' if_summary ']==2? ' Yes ': ' No ';
Later found in Baidu is the
Php ternary operator knowledge summary. Php trielement operator knowledge summary trielement operator syntax: condition? Result 1: Result 2: The position in front of the question mark is the condition for judgment. if the condition is met, result 1 is returned. if the condition is not met, the php ternary operator knowledge is collected.
Ternary operator syntax:
Today we are going to explain in PHP operator "
Ternary operators”。
Introduction to Ternary operators
The ternary operator is often used in programming, which is also called the "Trinocular operator", as his name requires three operands, and his role is to select one of the other two expressions based on an expression instead of selecting one in two statements o
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.